package com.hx.xiao.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hx.xiao.entity.Hou;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author hx
 * @since 2024-03-21
 */
public interface HouMapper extends BaseMapper<Hou> {



    @Update("update shou set history=#{history} where id=#{id}")
    int updateByHistory(String history,int id);

    @Update("update shou set collect=#{collect} where id=#{id}")
    int updateByCollect(String collect,int id);

    @Select("select s.id,s.ztext,s.ctime,s.biaoti,s.shenstart,s.faname,u.htime from hou s,su u,users us where us.id=u.uid and s.id=u.history and us.id=#{id}")
    List<Hou>   findAllHistory(Integer id);

    @Select("select s.id,s.ztext,s.ctime,s.biaoti,s.shenstart,s.faname from hou s,su u,users us where us.id=u.uid and s.id=u.collect and us.id=#{id}")
    List<Hou>   findAllCollect(Integer id);

    @Select("select s.id,s.ztext,s.ctime,s.biaoti,s.shenstart,s.faname from hou s where s.biaoti like '%${biaoti}%'")
    List<Hou>   findName(String biaoti);

    @Select("select s.id,s.ztext,s.ctime,s.biaoti,s.shenstart,s.faname from hou s where komg=#{komg}")
    List<Hou> findAllKome(String kome);


    @Update("update hou set ztext=#{ztext},ctime=#{ctime},biaoti=#{biaoti},shenstart=#{shenstart},faname=#{faname} where id=#{id}")
    int updateB(Hou hou);

    @Delete("delete from hou where id=#{id}")
    int deleteB(Integer id);

    @Insert("insert into hou(ztext,ctime,biaoti,shenstart,faname) values (#{ztext},#{ctime},#{biaoti},#{shenstart},#{faname})")
    int insertB(Hou hou);

}
